import React, { Component } from 'react';
import { NavBar, Rate } from 'antd-mobile'
class Index extends Component {
	state = {
		activeCount: 0
	}
	handleChange = (value) => {
		if(!localStorage.getItem('token')) {
			this.props.history.push({ pathname: '/login' })
			return 
		}

		this.setState({
			activeCount: value
		})
	}
	render() {
		const { history, location, match } = this.props
		const { activeCount } = this.state

		return (
			<div>
				<NavBar 
					onBack={ this.props.history.goBack }
					right={ <Rate count={ 1 } value={ activeCount } onChange={ this.handleChange }/> }
				>详情</NavBar>
				<img src={ location.state.url } alt="" width="100%"/>
				<h3>{ location.state.title }</h3>
				<p>{ location.state.desc }</p>
			</div>
		);
	}
}

export default Index;
